package com.wyb.controller;

import com.wyb.constant.Result;
import com.wyb.pojo.User;
import com.wyb.service.LoginService;
import com.wyb.service.UpdateUserServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class LoginController {
    @Autowired
    private LoginService loginService;
    @Autowired
    private UpdateUserServcie updateUserServcie;

    @PostMapping("/login")
    public Result login(@RequestBody User user) {
        return loginService.login(user);
    }

    @GetMapping("/logout")
    public Result logout() {
        return loginService.logout();
    }

    @GetMapping("/getuser")
    public Result getuUser(@RequestHeader String token){
        return loginService.getUser(token);
    }

    @PostMapping("/updateuser")
    public Result updateUser(@RequestBody User user){

        return updateUserServcie.updateUser(user);
    }
}
